home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP05.ZIP / CHAP05 / COSCHMOO / COSCHMOO.H < prev    next >
C/C++ Source or Header  |  1993-04-13  |  5KB  |  197 lines

  1. /*
  2.  * COSCHMOO.H
  3.  * Component Schmoo Chapter 5
  4.  *
  5.  * Single include file that pulls in everything needed for other source
  6.  * files in the Schmoo application.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18. #ifndef _COSCHMOO_H_
  19. #define _COSCHMOO_H_
  20.  
  21. #include <windows.h>
  22. #include <memory.h>
  23. //CHAPTER5MOD
  24. #include <ole2.h>
  25. #include <ole2ver.h>
  26. #include <bookguid.h>
  27. #include <ipoly5.h>
  28. //End CHAPTER5MOD
  29.  
  30. //These include files reference DLLs that don't have extern "C" already
  31. extern "C"
  32.     {
  33.     #include <commdlg.h>
  34.     }
  35.  
  36. #include <classlib.h>
  37. #include "resource.h"
  38.  
  39.  
  40. //COSCHMOO.CPP:  Frame object that creates a main window
  41.  
  42. class __far CSchmooFrame : public CFrame
  43.     {
  44.     private:
  45.         HBITMAP         m_hBmpLines[5];     //Menu item bitmaps
  46.  
  47.         BOOL            m_fInitialized;     //CoInitialize work?
  48.  
  49.     protected:
  50.         //Overridable for creating a CClient for this frame
  51.         virtual LPCClient CreateCClient(void);
  52.  
  53.         //FRegisterAllClasses override unneccessary with Polyline DLL
  54.         virtual BOOL      FPreShowInit(void);
  55.         virtual UINT      CreateGizmos(void);
  56.  
  57.         virtual LRESULT   OnCommand(HWND, WPARAM, LPARAM);
  58.         virtual void      OnDocumentDataChange(LPCDocument);
  59.         virtual void      OnDocumentActivate(LPCDocument);
  60.  
  61.         //New for this class
  62.         virtual void      CreateLineMenu(void);
  63.  
  64.     public:
  65.         CSchmooFrame(HINSTANCE, HINSTANCE, LPSTR, int);
  66.         virtual ~CSchmooFrame(void);
  67.  
  68.         //Overrides
  69.         virtual BOOL      FInit(LPFRAMEINIT);
  70.         virtual void      UpdateMenus(HMENU, UINT);
  71.         virtual void      UpdateGizmos(void);
  72.  
  73.         //New for this class
  74.         virtual void      CheckLineSelection(UINT);
  75.     };
  76.  
  77.  
  78. typedef CSchmooFrame FAR * LPCSchmooFrame;
  79.  
  80.  
  81.  
  82.  
  83.  
  84. //CLIENT.CPP
  85.  
  86. /*
  87.  * The only reason we have a derived class here is to override
  88.  * CreateCDocument so we can create our own type as well as
  89.  * overriding NewDocument to perform one other piece of work once the
  90.  * document's been created.
  91.  */
  92.  
  93. class __far CSchmooClient : public CClient
  94.     {
  95.     protected:
  96.         //Overridable for creating a new CDocument
  97.         virtual LPCDocument CreateCDocument();
  98.  
  99.     public:
  100.         CSchmooClient(HINSTANCE);
  101.         virtual ~CSchmooClient(void);
  102.  
  103.         virtual LPCDocument NewDocument(BOOL, LPCDocumentAdviseSink);
  104.     };
  105.  
  106.  
  107. typedef CSchmooClient FAR * LPCSchmooClient;
  108.  
  109.  
  110.  
  111.  
  112. //DOCUMENT.CPP
  113.  
  114. //Explicit CPolyline moved into Polyline DLL and hidden from us.
  115. class __far CPolylineAdviseSink : public IPolylineAdviseSink5
  116.     {
  117.     private:
  118.         LPVOID      m_pv;                       //Customizable structure
  119.         ULONG       m_cRef;
  120.  
  121.     public:
  122.         CPolylineAdviseSink(LPVOID);
  123.         ~CPolylineAdviseSink(void);
  124.  
  125.         //IUnknown members
  126.         STDMETHODIMP         QueryInterface(REFIID, LPVOID FAR *);
  127.         STDMETHODIMP_(ULONG) AddRef(void);
  128.         STDMETHODIMP_(ULONG) Release(void);
  129.  
  130.         //Advise members.
  131.         STDMETHODIMP_(void) OnPointChange(void);
  132.         STDMETHODIMP_(void) OnSizeChange(void);
  133.         STDMETHODIMP_(void) OnDataChange(void);
  134.         STDMETHODIMP_(void) OnColorChange(void);
  135.         STDMETHODIMP_(void) OnLineStyleChange(void);
  136.     };
  137.  
  138. typedef CPolylineAdviseSink FAR * LPCPolylineAdviseSink;
  139.  
  140.  
  141.  
  142. //Constant ID for the window polyline that lives in a document window
  143. #define ID_POLYLINE         10
  144.  
  145.  
  146. class __far CSchmooDoc : public CDocument
  147.     {
  148.     friend class CPolylineAdviseSink;
  149.  
  150.     protected:
  151.         UINT            m_uPrevSize;        //Last WM_SIZE wParam
  152.  
  153.         LPPOLYLINE              m_pPL;      //Polyline Editor window in us.
  154.         LPPOLYLINEADVISESINK    m_pPLAdv;   //Advises from Polyline
  155.  
  156.         //CHAPTER5MOD
  157.         LPPERSISTSTORAGE        m_pIPersistStorage; //Polyline's storage
  158.         //End CHAPTER5MOD
  159.  
  160.     protected:
  161.         virtual BOOL    FMessageHook(HWND, UINT, WPARAM, LPARAM, LRESULT FAR *);
  162.  
  163.     public:
  164.         CSchmooDoc(HINSTANCE);
  165.         virtual ~CSchmooDoc(void);
  166.  
  167.         virtual BOOL     FInit(LPDOCUMENTINIT);
  168.  
  169.         virtual void     Clear();
  170.  
  171.         virtual UINT     ULoad(BOOL, LPSTR);
  172.         virtual UINT     USave(UINT, LPSTR);
  173.  
  174.         virtual void     Undo(void);
  175.         virtual BOOL     FClip(HWND, BOOL);
  176.         virtual HGLOBAL  RenderFormat(UINT);
  177.         virtual BOOL     FQueryPaste(void);
  178.         virtual BOOL     FPaste(HWND);
  179.  
  180.         virtual COLORREF ColorSet(UINT, COLORREF);
  181.         virtual COLORREF ColorGet(UINT);
  182.  
  183.         virtual UINT     LineStyleSet(UINT);
  184.         virtual UINT     LineStyleGet();
  185.     };
  186.  
  187. typedef CSchmooDoc FAR * LPCSchmooDoc;
  188.  
  189.  
  190. //These color indices wrap the polyline definitions
  191. #define DOCCOLOR_BACKGROUND             POLYLINECOLOR_BACKGROUND
  192. #define DOCCOLOR_LINE                   POLYLINECOLOR_LINE
  193.  
  194.  
  195.  
  196. #endif //_COSCHMOO_H_
  197.